/*------------------------------------------------------------------------------------------------\
| Horrible X-Wing game by Steven Haber
| st_haber@hotmail.com
|
| star.cpp: contains class Star, which is a scrolling star from the randomly generated background
\------------------------------------------------------------------------------------------------*/

#include "Star.h"


//Constructor, takes a sprite, initial Y position, and a pointer to the render window
Star::Star(sf::Sprite *sprites[], int initial, sf::RenderWindow *out)
{
	mNewStar = *sprites[STAR];
	mOut = out;

	mNewStar.SetTop((float)SCREENY/STARS * initial);
	mNewStar.SetLeft((float)sf::Randomizer::Random(0, SCREENX));
		//Random value for X, because it looks cool
}


//Moves the star and draws it to the buffer
void Star::drawStar(float delta)
{
	mNewStar.Move(0, STARVELOCITY * delta);
	
	//Moves a star from the bottom back to the top
	if(mNewStar.GetTop() >= SCREENY)
	{
		mNewStar.SetTop(mNewStar.GetTop() - SCREENY);
		mNewStar.SetLeft((float)sf::Randomizer::Random(0, SCREENX));
	}
	
	mOut -> Draw(mNewStar);
}